<!--{template common/header_simple_start}-->
<link href="static/css/common.css?{VERHASH}" rel="stylesheet" media="all">
<link href="dzz/share/images/share.css?{VERHASH}" rel="stylesheet" media="all">
<script type="text/javascript" src="static/js/jquery.leftDrager.js?{VERHASH}"></script>

<!--{template common/header_simple_end}-->
<nav class="navbar navbar-default bs-navbar-default navbar-fixed-top" role="navigation" style="margin:0;padding:0 10px;">
  <ul class="nav nav-pills tag-container nav-pills-bottomguide clearfix" >
    <li><a href="{DZZSCRIPT}?mod=share">全部</a> </li>
    <li class="pull-right " style="margin:4px 0;">
      <form name="search" action="{DZZSCRIPT}" method="get">
        <input type="hidden" name="mod" value="share" />
        <div class="input-group" style="width:180px">
          <input name="keyword"  type="text" class="form-control input-sm" value="$keyword"  placeholder="分享标题">
          <a class="input-group-addon" herf="javascript:;" onclick="this.parentNode.parentNode.submit()"><i class="glyphicon glyphicon-search"></i></a> </div>
      </form>
    </li>
    <li class="pull-right gray" style="margin:4px 0;line-height:30px;padding-right:10px;font-size:12px">已加载<span class="loaded-num">{eval echo count($list);}</span>个<span class="total-num">，共 $count 个</span></li>
  </ul>
  </div>
</nav>
<div class="bs-container clearfix" >
  <div class="bs-main-container">
    <div class="main-content clearfix"> 
    <!--{if !$count}-->
        <div node-type="module" class="module-share-empty text-center clearfix">
            <div class="no-result-div" style="padding-top:40px;">
                <p class="no-result-pic"><em class="shr"></em></p>
                <p class="no-result-title">好东西要晒出来，快把你的文件分享给身边的朋友们吧。</p>
            </div>
        </div>
     <!--{else}-->
        <div node-type="module" class="module-list-toolbar" style="display: none;">
          <div class="bar clearfix"> 
          	<span node-type="chk" class="chk-box"> 
            	<span class="chk"></span> 
             </span> 
             <span class="text"> 已选中<span node-type="num">0</span>个文件/文件夹</span> 
             <button class="btn btn-sm btn-danger" data-key="unshare" ><span>取消分享</span> </button>
           </div>
        </div>
        <div node-type="module" class="module-list-view">
          <div node-type="wrapper" class="list-view-home">
            <div node-type="title" class="title" style="padding-right: 16px;">
              <div class="item clearfix"> 
                <!-- 第一列 -->
                <div node-type="title-col" data-key="name" class="col c1" style="width: 50%"> 
                    <span node-type="chk-all" class="chk"> <span class="chk-ico"></span> </span>
                    <div class="name"> <span>分享文件</span> <span node-type="order-status" class="asc desc" style="visibility: hidden;"></span> </div>
                </div>
                <!-- 其他列 -->
                <div node-type="title-col" data-key="dateline" class="col" style="width: 20%;
                "> 分享时间 <span node-type="order-status" class="asc desc" style="visibility: visible;"></span> </div>
                <div node-type="title-col" data-key="count" class="col" style="width: 9%;
                "> 浏览次数 <span node-type="order-status" class="asc desc" style="visibility: hidden;"></span> </div>
                <div node-type="title-col" data-key="size" class="col" style="width: 9%;
                "> 文件大小 <span node-type="order-status" class="asc desc" style="visibility: hidden;"></span> </div>
                <div node-type="title-col" data-key="type" class="col" style="width: 9%;
                border-right: none;"> 文件类型 <span node-type="order-status" class="asc desc" style="visibility: hidden;"></span> </div>
              </div>
             
            </div>
            <div node-type="list" class="list list-share clearfix" >
              <div class="list-wrapper clearfix">
                <!--{loop $list $value}-->
                  <div node-type="item" data-sid="$value[sid]" data-status="$value[status]" class="item clearfix"> 
                    <!-- 第一列 -->
                    <div class="col c1 name" style="width: 50%;" data-name="$value[title]"> 
                          <span node-type="chk" class="chk"> <span class="chk-ico"></span></span> 
                          <!-- 私密分享图标 --> 
                          <!--{if $value[password]}--><span class="ico-private-share" title="密码分享"></span> <!--{/if}--> 
                                            
                          <div node-type="name" class="name" title="$value[title]">
                            <!--{if $value[img]}--><img class="icon" src="$value[img]" /><!--{/if}-->
                            <!--{if $value[status]<0}--><span node-type="name-tip" style="color: red;">($value[fstatus])</span><!--{/if}-->
                            <span class="name-text-wrapper"> <span node-type="name-text"  data-href="$value[shareurl]" class="name-text enabled">$value[title]</span> </span> 
                          </div>
                         
                     </div>
                     
                    <!-- 其他列 -->
                    <div class="col dateline" style="width: 20%" data-dateline="$value[dateline]">$value[fdateline]</div>
                    <div class="col count" style="width: 9%" data-count="$value[count]">$value[count]次</div>
                    <div class="col size" style="width: 9%" data-size="$value[size]">$value[fsize]</div>
                    <div class="col type" style="width: 9%" data-type="$value[ftype]">$value[ftype]</div>
                    
                    <!-- 复制 -->
                    <div node-type="copy-bar" class="copy-bar"> 
                        <!--{if $value[qrcode]}--><a href="javascript:;" class="qrcode glyphicon glyphicon-qrcode" title="扫描二维码,发送到手机"  data-container="body" data-html="true" data-trigger="hover" data-toggle="popover" data-placement="right" data-content="<p class='text-center'><img src='$value[qrcode]'></p>"></a><!--{/if}-->
                        分享链接：<a href="$value[shareurl]" target="_blank">$value[shareurl]</a> 
                        <!--{if $value[password]}-->&nbsp;提取密码：$value[password] <!--{/if}--> 
                        &nbsp;<button class="btn btn-sm btn-default js_copy"  data-clipboard-text="{eval echo $value[password]?('链接:'.$value[shareurl].'  密码:'.$value[password]):$value[shareurl];}" style="position:relative"><i class="glyphicon glyphicon-duplicate"></i> 复制<span class="alert copy-success  alert-success hide ">复制成功,请粘帖到您需要的地方</span></button>
                        <!--{if $value[endtime]}-->&nbsp;到期时间：$value[fendtime] <!--{/if}--> 
                        <!--{if $value[times]}-->&nbsp;限制次数：$value[count] / $value[times] <!--{/if}--> 
                    </div>
                    <!--{if $value[downurl]}-->
                    <div node-type="copy-bar" class="copy-bar"> 
                        下载链接：<a href="$value[downurl]" target="_blank">$value[downurl]</a> 
                         <!--{if $value[password]}-->&nbsp;提取密码：$value[password] <!--{/if}--> 
                        &nbsp;<button class="btn btn-sm btn-default js_copy"  data-clipboard-text="{eval echo $value[password]?('下载链接:'.$value[downurl].'  密码:'.$value[password]):$value[downurl];}" style="position:relative"><i class="glyphicon glyphicon-duplicate"></i> 复制<span class="alert copy-success  alert-success hide ">复制成功,请粘帖到您需要的地方</span></button>
                    </div>
                    <!--{/if}-->
                  </div>
                <!--{/loop}-->
                <!--{if $nextpage}-->
                <div class="more text-center clearfix" onclick="getMore(this,'$nextpage')">加载更多</div>
                <!--{/if}-->
              </div>
            </div>
          </div>
		</div>
     <!--{/if}-->
    </div>
  </div>
</div>
<script type="text/javascript">
jQuery('.left-drager').leftDrager_layout(function(){
	jQuery('.list').css('height',jQuery('.bs-main-container').outerHeight(true)-jQuery('.list-view-home .title').outerHeight(true));
});
jQuery('.list-share').scroll(function(e) {
	var clientHeight = jQuery('.list-share').height();
	var scrollHeight = jQuery('.list-wrapper').height();
    if(jQuery('.list-share').scrollTop()+clientHeight>=scrollHeight-5) jQuery('.more').trigger('click');
});
function getMore(obj,page){
	jQuery(obj).html('<img src="dzz/images/loading.gif">正在加载...');
	jQuery.get('$theurl&page='+page+'&inajax=1',function(html){
		jQuery(obj).replaceWith(html);
		setLoadedNum();
	});
}
function setLoadedNum(){
	jQuery('.loaded-num').html(jQuery('.list-share .item').length);
}
jQuery(document).ready(function(e) {
    jQuery(document).on('mouseenter','div[node-type=item]',function(){
		jQuery(this).addClass('item-hover');
	});
	 jQuery(document).on('mouseleave','div[node-type=item]',function(){
		jQuery(this).removeClass('item-hover');
	});
	 jQuery(document).on('click','span[node-type=name-text]',function(){
		if(top._config){
			top.OpenWindow('url',jQuery(this).data('href'),jQuery(this).html(),null,{"img":jQuery(this).closest('.name').find('img.icon').attr('src'),"name":jQuery(this).html()});
		}else{
			window.open(jQuery(this).data('href'),jQuery(this).html());
		}
	});
	jQuery('.chk[node-type=chk-all]').on('click',function(){
		jQuery(this).addClass('chked');
		jQuery('.item').each(function(){
			jQuery(this).addClass('item-active').find('span[node-type=chk]').addClass('chked');
		});
		refresh_header();
	});
	jQuery(document).on('click','.item .chk',function(){
		jQuery(this).toggleClass('chked');
		jQuery(this).closest('.item').toggleClass('item-active');
		jQuery('.copy-bar').hide();
		refresh_header();
		return false;
	});
	jQuery('.module-list-toolbar .chk').on('click',function(){
		if(jQuery(this).hasClass('chked')){
			jQuery(this).removeClass('chked');
			jQuery('.chk[node-type=chk-all]').removeClass('chked');
			jQuery('.module-list-toolbar').hide();
			jQuery('.item.item-active').each(function(){
				jQuery(this).removeClass('item-active').find('span[node-type=chk]').removeClass('chked');
				jQuery(this).find('.copy-bar').hide();
			});
		}else{
			jQuery(this).addClass('chked');
			jQuery('.item:not(.item-active)').each(function(){
				jQuery(this).addClass('item-active').find('span[node-type=chk]').addClass('chked');
			});
		}
	});
	jQuery(document).on('click','div[node-type=item]',function(e){
		e=e?e:event;
		var el=jQuery(this);
		var actives=jQuery('.item-active').length;
		if(e.ctrlKey){
			jQuery('.item-active').not(this).find('.copy-bar').hide();
		}else{
			jQuery('.item-active').not(this).each(function(){
				jQuery(this).removeClass('item-active').find('span[node-type=chk]').removeClass('chked')
				.end().find('.copy-bar').hide();
			});
		}
		if(el.hasClass('item-active') && (actives==1 || e.ctrlKey)){
			el.removeClass('item-active').find('span[node-type=chk]').removeClass('chked');
			el.find('.copy-bar').hide();
		}else{
			el.addClass('item-active').find('span[node-type=chk]').addClass('chked');
			if(parseInt(el.data('status'))>-1) el.find('.copy-bar').show();
		}
		refresh_header();
	});
	 var client = new ZeroClipboard(jQuery('.js_copy'));
	  client.on( "load", function( client ) {
		  client.on( "complete", function( client,args ) {
			  var self=this;
			  jQuery(this).parent().find('.copy-success').removeClass('hide');
			  window.setTimeout(function(){
					jQuery(self).parent().find('.copy-success').addClass('hide');
			  },1000);
		  });
	 });
	 jQuery('.title .item .col[node-type=title-col]').on('click',function(){
		 var el=jQuery(this);
		 el.find('.asc').css('visibility','visible').toggleClass('desc');
		 el.siblings().find('.asc').css('visibility','hidden');
		 item_sort(el.data('key'), el.find('.asc').hasClass('desc')?'desc':'asc');
	 });
	 jQuery('button[data-key=unshare]').on('click',function(){
		 var msg='<p class="text-center">取消分享后，该条分享记录将被删除，好友将无法再访问此分享链接。</p><p class="text-center">你确认要取消分享吗？</p>';
		 showDialog(msg, 'confirm', '确认取消分享', share_delete, 1)
	 });
	 jQuery(document).on('click','.qrcode',function(){
		 jQuery(this).popover('toggle');return false;
	 });
	 /*jQuery(document).on('mouseleave','.qrcode,.qrcode-zoom',function(){
		  jQuery(this).removeClass('qrcode-zoom');
	 });*/
	 jQuery('[data-toggle="popover"]').popover();
	 setLoadedNum();
});

function item_sort(key,order){
	
	var sarr=new Array();
	jQuery('.list-share .item').each(function(index){
		sarr.push((jQuery(this).find('.col.'+key).data(key))+'____'+index);
	});
	if(key=='dateline' || key=='size'){
		sarr=sarr.sort(function(a,b){
			return (parseInt(a)-parseInt(b));
		});
	}else{
		sarr=sarr.sort();
	}
	var frage=document.createDocumentFragment();
	var list=jQuery('.list-share .item');
	if(order=='desc'){
		for(var i=sarr.length-1;i>=0;i--){
			var index=sarr[i].split('____')[1];
			frage.appendChild(list.get(index));
		}
	}else{
		for(var i=0;i<sarr.length;i++){
			var index=parseInt(sarr[i].split('____')[1]);
			frage.appendChild(list.get(index));
		}
	}
	var page=jQuery('.list-wrapper .more').clone();
	jQuery(frage).appendTo(jQuery('.list .list-wrapper').empty());
	page.appendTo('.list .list-wrapper');
}
function share_delete(){
	var sids=new Array();
	jQuery('.list .item-active').each(function(){
		sids.push(jQuery(this).data('sid'));
	});
	jQuery.post(DZZSCRIPT+'?mod=share&op=ajax&do=delete',{"sids":sids},function(json){
		if(json.msg=='success'){
			showmessage('取消分享成功','success',2000,1);
			jQuery('.list .item-active').remove();
			refresh_header();
		}else{
			showmessage(json.error,'danger',3000,1);
		}
	},'json');
}
function refresh_header(){
	var sum=jQuery('.list .item.item-active').length;
	var tsum=jQuery('.list .item').length;
	if(sum>0){
		jQuery('.module-list-toolbar').find('span[node-type=num]').html(sum).end().show();
		if(sum==tsum){
			 jQuery('.module-list-toolbar').find('.chk').addClass('chked');
		}else{
			 jQuery('.module-list-toolbar').find('.chk').removeClass('chked');
		}
	}else{
		jQuery('.module-list-toolbar').hide();
		jQuery('.chk[node-type=chk-all]').removeClass('chked');
	}
}
</script> 
<!--{template common/footer_simple}--> 
<script type="text/javascript" src="static/js/ZeroClipboard/ZeroClipboard.min.js?{VERHASH}"></script>
<script src="static/bootstrap/js/bootstrap.min.js?{VERHASH}"></script> 
